<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='日志管理',active='logs'">
<header th:replace="admin/header::headerFragment(${title},${active})"></header>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="admin/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">日志管理</h4>
                    </div>
                    <div class="col-md-12">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>动作</th>
                                <th>作者编号</th>
                                <th>IP地址</th>
                                <th>位置信息</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <th:block th:each="log : ${logs.list}">
                                <tr>
                                    <td th:text="${log.id}"></td>
                                    <td th:text="${log.action}"></td>
                                    <td th:text="${log.author_id}"></td>
                                    <td th:text="${log.ip}"></td>
                                    <td th:text="${log.data}"></td>
                                    <td th:text="${commons.fmtdate(log.created, 'yyyy-MM-dd HH:mm:ss')}"></td>
                                    <td>
                                        <a href="javascript:void(0)" th:onclick="'delComment('+${log.id}+');'"
                                           class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
                                                class="fa fa-trash-o"></i> <span>删除</span></a>
                                    </td>
                                </tr>
                            </th:block>
                            </tbody>
                        </table>
                        <div th:replace="comm/macros :: pageAdminNav(${logs})"></div>
                    </div>
                </div>
                <div th:replace="admin/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<div th:replace="admin/footer :: footer"></div>
<script type="text/javascript">
    /*<![CDATA[*/
    var tale = new $.tale();

    function delComment(coid) {
        tale.alertConfirm({
            title: '确定删除该评论吗?',
            then: function () {
                tale.post({
                    url: '/admin/comments/delete',
                    data: {coid: coid},
                    success: function (result) {
                        if (result && result.success) {
                            tale.alertOkAndReload('评论删除成功');
                        } else {
                            tale.alertError(result.msg || '评论删除失败');
                        }
                    }
                });
            }
        });
    }

    function updateStatus(coid) {
        tale.alertConfirm({
            title: '确定审核通过吗?',
            then: function () {
                tale.post({
                    url: '/admin/comments/status',
                    data: {coid: coid, status: "approved"},
                    success: function (result) {
                        if (result && result.success) {
                            tale.alertOkAndReload('评论状态设置成功');
                        } else {
                            tale.alertError(result.msg || '评论设置失败');
                        }
                    }
                });
            }
        });
    }
    /*]]>*/
</script>
</body>
</html>